home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / UsingPDF / GhostScript / source / gs5.10 / gsdps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-16  |  3.0 KB  |  130 lines

  1. /* Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gsdps.c */
  20. /* Display PostScript extensions */
  21. #include "gx.h"
  22. #include "gsdps.h"
  23. #include "gspath.h"        /* for newpath */
  24. #include "gxdevice.h"        /* for gxcpath.h */
  25. #include "gzpath.h"        /* for gzcpath.h */
  26. #include "gzstate.h"
  27. #include "gzcpath.h"
  28.  
  29. #ifdef DPNEXT
  30.  
  31. /* Forward references */
  32. private int common_viewclip(P2(gs_state *, int));
  33.  
  34. int
  35. gs_initviewclip(gs_state *pgs)
  36. {    const gx_clip_path *pcpath = pgs->view_clip->path;
  37.  
  38.     if ( pcpath->rule != 0 ) {
  39.       gx_cpath_release(pcpath);
  40.       gx_cpath_init(pcpath, pcpath->path.memory);
  41.       pcpath->rule = 0;
  42.     }
  43.     return 0;
  44. }
  45.  
  46. int
  47. gs_viewclip(gs_state *pgs)
  48. {    return common_viewclip(pgs, gx_rule_winding_number);
  49. }
  50.  
  51. int
  52. gs_eoviewclip(gs_state *pgs)
  53. {    return common_viewclip(pgs, gx_rule_even_odd);
  54. }
  55.  
  56. private int
  57. common_viewclip(gs_state *pgs, int rule)
  58. {    /*
  59.      * Temporarily substitute the view clip path for the clip path
  60.      * so we can use gx_clip_to_path.
  61.      */
  62.     gx_clip_path *save_cpath = pgs->clip_path;
  63.     int code;
  64.  
  65.     pgs->clip_path = pgs->view_clip->path;
  66.     code = gx_clip_to_path(pgs);
  67.     pgs->clip_path = save_cpath;
  68.     if ( code >= 0 )
  69.       gs_newpath(pgs);
  70.     return code;
  71. }
  72.  
  73. int
  74. gs_viewclippath(gs_state *pgs)
  75. {    gx_path cpath;
  76.     const gx_clip_path *pcpath = pgs->view_clip->path;
  77.     int code;
  78.  
  79.     if ( pcpath->rule == 0 ) {
  80.       /*
  81.        * No view clip path is active: fabricate one.
  82.        ****** SHOULD USE IMAGEABLE AREA, NOT ENTIRE PAGE ******
  83.        */
  84.       const gx_device *dev = pgs->device;
  85.  
  86.       gx_path_init(&cpath, pgs->memory);
  87.       code = gx_path_add_rectangle(&cpath, fixed_0, fixed_0,
  88.                        int2fixed(dev->width),
  89.                        int2fixed(dev->height));
  90.     } else {
  91.       gx_path path;
  92.  
  93.       code = gx_cpath_path(pcpath, &path);
  94.       if ( code < 0 )
  95.         return code;
  96.       code = gx_path_copy(&path, &cpath, 1);
  97.     }
  98.     if ( code < 0 )
  99.       return code;
  100.     gx_path_release(pgs->path);
  101.     *pgs->path = cpath;
  102.     return 0;
  103. }
  104.  
  105. #else                /* !DPNEXT */
  106.  
  107. /* Provide dummy definitions, since gs_state.view_clip doesn't exist. */
  108.  
  109. int
  110. gs_initviewclip(gs_state *pgs)
  111. {    return 0;
  112. }
  113.  
  114. int
  115. gs_viewclip(gs_state *pgs)
  116. {    return gs_newpath(pgs);
  117. }
  118.  
  119. int
  120. gs_eoviewclip(gs_state *pgs)
  121. {    return gs_newpath(pgs);
  122. }
  123.  
  124. int
  125. gs_viewclippath(gs_state *pgs)
  126. {    return gs_initclip(pgs);
  127. }
  128.  
  129. #endif
  130.